<?php echo $this->doctype(); ?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/">
    <head>
		<meta charset="utf-8" />
        <!-- For testing -->
        <title>title for testing</title>
        <meta name="description" content="Tab: description for testing" />        
        <meta property="og:image" content="http://cache.lifehacker.com/assets/images/17/2011/10/fb_sharetog_.jpg" />

        <!-- End -->
		<?php if (!Core_Util::isFacebookRequest()): ?>
			<script type="text/javascript">
				if( top === window )
				{
					top.location.href = "<?php echo $this->pageUrl(array('_full' => true, '_target' => 'top')) ?>";
				}
			</script>
		<?php endif ?>
        <title><?php echo $this->translate('APP_NAME') . ' - ' . $this->id_page; ?></title>  
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css" type="text/css" media="all" />
		<link rel="stylesheet" type="text/css" href="<?php echo STATIC_URL . '/media/style/common.css?v=' . SKIN_VERSION ?>" />
		<link rel="stylesheet" type="text/css" href="<?php echo STATIC_URL . '/media/skin/main.css?v=' . SKIN_VERSION ?>" />
		<link rel="stylesheet" type="text/css" href="<?php echo REPOSITORY_URL . '/javascript/tipsy/tipsy.css?v=' . SKIN_VERSION?>" />
		<link rel="stylesheet" type="text/css" href="<?php echo STATIC_URL . "/media/style/jquery.Jcrop.css" ?>" />
        <?php $this->loadSkin($this->SKIN); ?>
		<?php echo $this->headLink(); ?>
		<?php echo $this->headScript(); ?>
		<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
		<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script>        
		<script type="text/javascript" src="<?php echo STATIC_URL . "/javascript/jquery.Jcrop.min.js" ?>"></script>
		<script type="text/javascript" src="<?php echo STATIC_URL . "/javascript/common.js" ?>"></script>
        <script type="text/javascript" src="<?php echo REPOSITORY_URL . '/javascript/tipsy/jquery.tipsy.js'?>" ></script>	
        <script type="text/javascript" src="<?php echo STATIC_URL . "/javascript/invite_friends.js" ?>"></script>
		<?php if ($this->contest->getBackgroundImageUrl()): ?>
			<style type="text/css">
				#background
				{
					background:url('<?php echo $this->contest->getBackgroundImageUrl(); ?>')!important;
				}
			</style>
			<link rel="stylesheet" type="text/css" href="<?php echo STATIC_URL . "/media/skin/background.css" ?>" />
		<?php endif; ?>
		<?php echo $this->social->render('initHead'); ?>
		<?php echo $this->headMeta(); ?>
    </head>
	<body>
		<div id="background">
		<div id="master_container" class="sm810">
			<?php echo $this->social->render('initBody'); ?>
			<?php if ($this->social->isPageAdmin()): ?>		
				   <div class="sm_admin_pannel" style="height:48px">
					<div class="sm_admin_setting">
						<a class="sm_admin_setting_text" target="_blank" title="Go to Admin" 
						   href="<?php echo $this->social->url('/contest/manage/list/id_page/' . $this->social->getIdPage()); ?>" >
							<?php echo $this->translate('ADMIN_PANEL')?>
						</a>
					</div>
					<div class="sm_paypal" style="float: right;">
						 <?php echo $this->partial('campaign.admin.phtml', 'payment', array('social' => $this->social));?>
					</div>
				</div>
			<?php else: ?>
				<?php echo $this->partial('campaign.phtml', 'payment', array('social' => $this->social));?>
			<?php endif; ?>
            <div class="sm_banner">
                <h2>
					<?php echo $this->escape($this->contest->getTitle()); ?>
                </h2>
				<?php
				$bannerLink = $this->contest->getBannerLink();
				if (!empty($bannerLink)):
					?>
					<a target="_blank" href="<?php echo $this->contest->getBannerLink(); ?>">
					<?php endif; ?>
					<img class="image_banner" src="<?php echo $this->contest->getBannerImageUrl(); ?>" style="max-width: 810px;" />
					<?php if (!empty($bannerLink)): ?>
					</a>
				<?php endif; ?>
            </div>
			<?php
			if (!empty($this->contest->id)):
				?>
	            <div class="sm_fanpage_menu">
	                <ul class="sm_fanpage_menu_action">
	                    <li id="view_entries">
	                        <a class="menu_action"
							   href="<?php echo $this->pageUrl(array('target' => 'view'), true); ?>">
								   <?php echo $this->translate('MENU_VIEW_ENTRIES'); ?>
	                        </a>
	                    </li>
	                    <li id="about_contest">
	                        <a class="menu_action" 
							   href="<?php echo $this->pageUrl(array('target' => 'about'), true); ?>">
								   <?php echo $this->translate('MENU_ABOUT_THIS_CONTEST'); ?>
	                        </a>
	                    </li>
						<?php if ($this->contest->isHasWinnerMessage()): ?>
							<li id="winners">
								<a class="menu_action" 
								   href="<?php echo $this->pageUrl(array('target' => 'winners'), true); ?>">
									   <?php echo $this->translate('MENU_WINNERS'); ?>
								</a>
							</li>
						<?php endif; ?>
	                    <li id="link_submit_entry" class="link_submit_entry">
	                        <a class="upload_action">
								<?php echo $this->translate('MENU_SUBMIT_AN_ENTRY'); ?>
	                        </a>
	                    </li>
	                </ul>
	                <script type="text/javascript">
						$(document).ready(function(){
                            
							Social.bind('#link_submit_entry', 'click', function(e){
									e.preventDefault();
									Social.redirect("<?php echo $this->social->pageUrl(array('target' => 'submit')); ?>");
								},{
									scope	: "<?php echo $this->social->getOauthScope() ?>",								
									title	: '<?php echo $this->translate('Cannot submit')?>',
									content	: '<?php echo $this->translate('Please authorize to submit')?>'
								}
							);
						});
	                </script>
	            </div> 

	            <div class="sm_fanpage_contents">
					<?php echo $this->layout()->content; ?>
	            </div>
			<?php else: ?>
	            <div class="sm_message_panel">
	                <p class="header"><?php echo $this->translate('MSG_NO_CONTEST_YET'); ?></p>
	            </div>
			<?php endif; ?>
		</div>
		</div>
        <div class ="footer_msg">
            <?php 
                
                $id_page = $this->social->getIdPage();
                $pagesTable = Core_Model_DbTable_Pages::getInstance();
                $name_page = $pagesTable->getNamePage( $id_page);
                $link_fanpage = $this->social->getFanPageUrl($id_page, $name_page) ;
            echo sprintf($this->translate('FOOTER_MSG'), "<a target='top' href=\"$link_fanpage\">".$name_page."</a>")   
            ?>
        </div>
        
		<?php echo $this->partial('footer.phtml', 'payment', array(
			'img_extended_class'	=> (APP_INSTANCE === APP_INSTANCE_IMAGE)?'image':'video',
			'social'				=> $this->social
		)) ?>
        
        
        <?php
            if(!empty($this->contest->google_analytics_id))
            {
                echo $this->partial('google_analytics/google_analytics.phtml', array('google_analytics_id' => $this->contest->google_analytics_id));
            }
        ?>
		<?php echo $this->social->render('endBody') ?>
	</body>
</html>
